<!--  -->
<template>
    <div class="container-bg">
      <div class="filter-container" v-if="false">
        <el-select
          v-model="deviceId"
          class="filter-item"
          placeholder="请选择设备"
          @change="getData"
        >
          <el-option
            v-for="(item, index) of machineList"
            :key="index"
            :label="item.name"
            :value="item.deviceId"
          />
        </el-select>
      </div>

      <el-form
        ref="elForm"
        :model="formData"
        :rules="rules"
        size="medium"
        label-width="160px"
      >
        <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="人脸最小像素" prop="iFaceMinPixel">
              <el-slider
                :max="200"
                :step="1"
                v-model="formData.iFaceMinPixel"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸检测阈值" prop="iFaceDetectionThreshold">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iFaceDetectionThreshold"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸识别阈值" prop="iFaceRecognitionThreshold">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iFaceRecognitionThreshold"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="RGB活体检测阈值" prop="iLiveDetectThreshold">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iLiveDetectThreshold"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="提示声量" prop="iPromptVolume">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iPromptVolume"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="检测眼镜阈值" prop="iGlassesScore">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iGlassesScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="检测太阳镜阈值" prop="iSunGlassesScore">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iSunGlassesScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="帽子检测阈值" prop="iHatScore">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iHatScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="口罩检测阈值" prop="iMaskScore">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iMaskScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="刘海与额头的比例阈值" prop="iBangsRatio">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iBangsRatio"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="允许口罩通过的阈值" prop="iMaskThreshold">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iMaskThreshold"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸亮度等级最大阈值" prop="iBrightMax">
              <el-slider
                :max="255"
                :step="1"
                v-model="formData.iBrightMax"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸亮度等级最小阈值" prop="iBrightMix">
              <el-slider
                :max="255"
                :step="1"
                v-model="formData.iBrightMix"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="俯仰角阈值" prop="iPitch">
              <el-slider
                :max="100"
                :step="1"
                v-model="formData.iPitch"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="偏航角阈值" prop="iYaw">
              <el-slider
                :max="90"
                :step="1"
                v-model="formData.iYaw"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="翻滚角阈值" prop="iRoll">
              <el-slider
                :max="90"
                :step="1"
                v-model="formData.iRoll"
                show-input
              ></el-slider>
            </el-form-item>
            <!--  -->
            <el-form-item label="模糊度阀值" prop="iBlurThreshold">
              <el-slider
                :max="70"
                :min="0"
                :step="1"
                v-model="formData.iBlurThreshold"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="红绿偏估最小值" prop="iDaMin">
              <el-slider
                :max="10"
                :min="0"
                :step="1"
                v-model="formData.iDaMin"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="红绿偏估最大值" prop="iDaMax">
              <el-slider
                :max="0"
                :min="-10"
                :step="1"
                v-model="formData.iDaMax"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="图像色彩偏差值" prop="iCast">
              <el-slider
                :max="50"
                :min="0"
                :step="1"
                v-model="formData.iCast"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="黄蓝最小偏估值" prop="iDbMin">
              <el-slider
                :max="10"
                :min="0"
                :step="1"
                v-model="formData.iDbMin"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="黄蓝最大偏估值" prop="iDbMax">
              <el-slider
                :max="0"
                :min="-10"
                :step="1"
                v-model="formData.iDbMax"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="图片颜色饱和度" prop="saturation">
              <el-slider
                :max="100"
                :min="-100"
                :step="1"
                v-model="formData.saturation"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="最大瞳孔距离" prop="iPupillaryDistanceMax">
              <el-slider
                :max="1280"
                :min="0"
                :step="1"
                v-model="formData.iPupillaryDistanceMax"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="最小瞳孔距离" prop="iPupillaryDistanceMin">
              <el-slider
                :max="1280"
                :min="0"
                :step="1"
                v-model="formData.iPupillaryDistanceMin"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="检测矿工的分数" prop="iMinerScore">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iMinerScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="矿工识别分数" prop="iMinerRecognizeScore">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iMinerRecognizeScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸框上边界阈值" prop="iPaddingTop">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iPaddingTop"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸框左边界阈值" prop="iPaddingLeft">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iPaddingLeft"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸框下边界阈值" prop="iPaddingBottom">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iPaddingBottom"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸框右边界阈值" prop="iPaddingRight">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iPaddingRight"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="IR活体阈值" prop="iIRLivenessScore">
              <el-slider
                :max="100"
                :min="0"
                :step="1"
                v-model="formData.iIRLivenessScore"
                show-input
              ></el-slider>
            </el-form-item>
            <el-form-item label="人脸最大像素" prop="iFaceMaxPixel">
              <el-slider
                :max="1280"
                :min="0"
                :step="1"
                v-model="formData.iFaceMaxPixel"
                show-input
              ></el-slider>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="人脸亮度等级" prop="sDetectBrightLevel">
              <el-switch v-model="formData.sDetectBrightLevel" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="额头刘海占比" prop="sDetectbangs">
              <el-switch v-model="formData.sDetectbangs" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="RGB活体检测不通过" prop="sLiveDetect">
              <el-switch v-model="formData.sLiveDetect" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="检测眼镜不通过" prop="sDetectGlasses">
              <el-switch v-model="formData.sDetectGlasses" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="检测太阳镜不通过" prop="sDetectSunGlasses">
              <el-switch v-model="formData.sDetectSunGlasses" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="检测帽子不通过" prop="sDetectHat">
              <el-switch v-model="formData.sDetectHat" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="口罩检测可通过" prop="sDetectMask">
              <el-switch v-model="formData.sDetectMask" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="模糊度检测开启" prop="sDetectBlur">
              <el-switch v-model="formData.sDetectBlur" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="色彩检测开启" prop="sColorAnalyze">
              <el-switch v-model="formData.sColorAnalyze" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="瞳孔距离开启" prop="sPupillaryDistance">
              <el-switch v-model="formData.sPupillaryDistance" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="是否开启矿工识别" prop="sMinerEnable">
              <el-switch v-model="formData.sMinerEnable" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
            <el-form-item label="是否开启IR活体" prop="sIRLivenessEnabled">
              <el-switch v-model="formData.sIRLivenessEnabled" active-color="#14CC0A" active-value="open" inactive-value="close"></el-switch>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item size="large">
          <el-button type="primary" size="medium" style="width:120px" :loading="btnLoading" @click="submitForm">保存</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
import { faceConfigApi,editFaceConfigApi} from "@/api/access/equipment";
export default {
  props:['id','formData'],
  name: "SelectMachine",
  data() {
    return {
      total: 0,
      machineList: [],
      rules: {},
      FACEPARA: {
        "FaceMinPixel": "人脸最小像素",
        "FaceDetectionThreshold": "人脸检测阈值",
        "FaceRecognitionThreshold": "人脸识别阈值",
        "LiveDetectThreshold": "活体检测阈值",
        "PromptVolume": "提示音量",
        "GlassesDetectThreshold": "检测眼镜阈值",
        "SunGlassesDetectThreshold" : "检测太阳镜阈值",
        "HatDetectThreshold": "帽子检测阈值",
        "MaskDetectThreshold": "口罩检测阈值",
        "BangsRatioDetectThreshold" : "刘海与人脸的比例阈值",
        "FaceBrightLevelThresholdMax" : "人脸亮度等级最大阈值",
        "MaskRecognizeThreshold": "允许口罩通过的阈值",
        "FaceBrightLevelThresholdMin" : "人脸亮度等级最小阈值",
        "PitchDetect" : "俯仰角阈值",
        "YawDetect" : "偏航角阈值",
        "RollDetect" : "翻滚角阈值",

        "FaceBrightLevel" : "人脸亮度等级",
        "BangsRatioDetect" : "额头刘海占比",
        "LiveDetect": "活体检测",
        "GlassesDetect": "检测眼镜",
        "SunGlassesDetect" : "检测太阳镜",
        "HatDetect": "帽子检测",
        "MaskDetect": "口罩检测可通过",
        "iPupillaryDistanceMax": "最大瞳孔距离",
        "iPupillaryDistanceMin": "最小瞳孔距离",
        "sPupillaryDistance": "瞳孔距离开启",
        "iMinerScore":"检测矿工的分数",
        "iMinerRecognizeScore":"矿工识别分数",
        "sMinerEnable":"是否开启矿工识别",
        "iPaddingTop":"人脸框上边界阈值",
        "iPaddingLeft":"人脸框左边界阈值",
        "iPaddingBottom":"人脸框下边界阈值",
        "iPaddingRight":"人脸框右边界阈值",
        "sIRLivenessEnabled":"是否开启IR活体",
        "iIRLivenessScore":"IR活体阈值",
        "iFaceMaxPixel":"人脸最大像素",
      },
      btnLoading:false,
      resetItem:{
        iFaceMinPixel:60,
        iFaceDetectionThreshold:60,
        iFaceRecognitionThreshold:73,
        iLiveDetectThreshold:70,
        iGlassesScore:50,
        iSunGlassesScore:50,
        iHatScore:50,
        iMaskScore:50,
        iBangsRatio:50,
        iBrightMax:210,
        iMaskThreshold:70,
        iBrightMix:60,
        iPitch:30,
        iYaw:30,
        iRoll:30,
        sDetectBrightLevel:'close',
        sDetectbangs:'close',
        sLiveDetect:'open',
        sDetectGlasses:'close',
        sDetectSunGlasses:'close',
        sDetectHat:'close',
        sDetectMask:'close',
        iBlurThreshold:35, //0 - 70   模糊度阀值
        iDaMin:0,//            0 - 10      红绿偏估最小值
        iDaMax: 0,//          -10 - 0     红绿偏估最大值
        iCast:0,//               0 - 50      图像色彩偏差值
        iDbMin:0,//           0 - 10       黄蓝最小偏估值
        iDbMax: 0,//         -10 - 0      黄蓝最大偏估值
        saturation:0,//       -100 - 100   图片颜色饱和度
        sDetectBlur:'close',       //模糊度检测开启
        sColorAnalyze:'close',   //色彩检测开启
        iPupillaryDistanceMax: 1280,
        iPupillaryDistanceMin: 0,
        sPupillaryDistance: "close",
        "iMinerScore":90,
        "iMinerRecognizeScore":80,
        "sMinerEnable":"close",
        "iPaddingTop":0,
        "iPaddingLeft":0,
        "iPaddingBottom":0,
        "iPaddingRight":0,
        "sIRLivenessEnabled":"close",
        "iIRLivenessScore":90,
        "iFaceMaxPixel":1280
      }
    };
  },
  created() {
  },
  methods: {
    submitForm(type) {
      if (+this.formData.iBrightMax < +this.formData.iBrightMix) {
        this.msgError('人脸亮度等级最大阈值 应大于 人脸亮度等级最小阈值');
        return false;
      }
      this.btnLoading = true;
      editFaceConfigApi(this.formData).then((response) => {
        // if (response) {
        //   this.formData = response;
        // }
        this.btnLoading = false;
        if (type == 1) {
          this.msgSuccess('重置成功');
        }else {
          this.msgSuccess('修改成功');
        }
      }).catch(err => {
        this.msgError('修改失败');
      });
    },
    resetForm() {
      let formData = Object.assign({},this.formData,this.resetItem);
      this.$emit('update:formData', formData);
      this.submitForm(1);
    },
  },
};
</script>


<style lang='scss' scoped>
</style>